package framework.model;

import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * Created by chencs on 2017/4/12.
 */
public class ResponseListUitl {
    private static final Logger logger = LoggerFactory.getLogger(ResponseListUitl.class);

    public static <E> String commonList(List<E> list) {
        ResponseListCommon<E> rs = new ResponseListCommon<E>();
        rs.setTotal(list.size());
        rs.setRows(list);
        String jsonstr = JSON.toJSONString(rs);
        logger.info("jsonstr = {}",jsonstr );
        return jsonstr;
    }

    public static <E> String commonPagerList(long total, List<E> list) {
        ResponseListCommon<E> rs = new ResponseListCommon<E>();
        rs.setTotal(total);
        rs.setRows(list);
        String jsonstr = JSON.toJSONString(rs);
        logger.info("jsonstr = {}",jsonstr );
        return jsonstr;
    }
}
